package com.ctgu.demo02.controller;

import com.ctgu.demo02.service.BooksService;
import com.ctgu.demo02.utils.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName BookController
 * @Author Alex2
 * @Date 2025/3/11 18:02
 **/

@RestController
@RequestMapping("/api/books")
public class BookController {

    @Autowired
    private BooksService booksService;

    // http://localhost:8080/api/books/insertBook?name=moon
    @GetMapping("insertBook")
    public ApiResult insertBook(@RequestParam String name) {
        return booksService.insertBooks(name);
    }

    // http://localhost:8080/api/books/deleteBook/1
    @GetMapping("deleteBook/{id}")
    public ApiResult deleteBookById(@PathVariable Integer id) {
        return booksService.deleteBookById(id);
    }

    // http://localhost:8080/api/books/getAllUnDelete
    @GetMapping("getAllUnDelete")
    public ApiResult getAllUnDelete() {
        return booksService.getAllUnDelete();
    }
}